//
//  SYLoginView.m
//  BSHOUYIFANG
//
//  Created by lanou3g on 15/8/18.
//  Copyright (c) 2015年 CYB. All rights reserved.
//

#import "SYLoginView.h"
#import "Header.h"

@implementation SYLoginView

-(instancetype)initWithFrame:(CGRect)frame
{
    self =[super initWithFrame:frame];
    if (self) {
        self.backgroundColor = [UIColor whiteColor];
        [self p_setupSubviews];
    }
    return self;
}

- (void)p_setupSubviews
{
    _phoneNumberTF = [[UITextField alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/12,SCREEN_WIDTH/4, SCREEN_WIDTH/1.2, SCREEN_WIDTH/10)];
    _passWordTF = [[UITextField alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/12, SCREEN_WIDTH/4 +SCREEN_WIDTH/10 +10 , SCREEN_WIDTH/1.2,SCREEN_WIDTH/10)];
    _phoneNumberTF.placeholder =@"手机号";
    _passWordTF.placeholder =@"密码";
    _phoneNumberTF.tag = 1000;
    _passWordTF.tag = 1001;
    _phoneNumberTF.borderStyle = UITextBorderStyleRoundedRect;
    _passWordTF.borderStyle = UITextBorderStyleRoundedRect;
   _passWordTF.secureTextEntry =YES;//设置密码保护；
    
    _longinButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _longinButton.frame = CGRectMake(SCREEN_WIDTH/12,SCREEN_HEIGHT/4+SCREEN_WIDTH/10+10,SCREEN_WIDTH/1.2,SCREEN_WIDTH/10);
    _longinButton.backgroundColor = [UIColor redColor];
    [_longinButton setTitle:@"登录" forState:UIControlStateNormal];
    _longinButton.titleLabel.textColor =[UIColor whiteColor];
    
    UILabel *protocolLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0,SCREEN_WIDTH/2.8,20)];
    protocolLabel.text =@"注册账号表示同意";
    protocolLabel.font = [UIFont systemFontOfSize:14];
    
    _protocolButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _protocolButton.frame = CGRectMake(SCREEN_WIDTH/3.1, 0,SCREEN_WIDTH/3.2,20);
    [_protocolButton setTitle:@"最终用户协议" forState:UIControlStateNormal];
    //_protocolButton.titleEdgeInsets = UIEdgeInsetsMake(0, SCREEN_WIDTH/3.4, 0, SCREEN_WIDTH/3);
    //_protocolButton.contentVerticalAlignment = UIControlContentHorizontalAlignmentFill;
    _protocolButton.titleLabel.font = [UIFont systemFontOfSize:14];
    [_protocolButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    
    UIView *LBView = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/5, SCREEN_HEIGHT/2.4, SCREEN_WIDTH/1.5, 20)];
    [LBView addSubview:protocolLabel];
    [LBView addSubview:_protocolButton];
    
    _registerButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _registerButton.frame = CGRectMake(SCREEN_WIDTH/4.2, SCREEN_HEIGHT/2.2, SCREEN_WIDTH/4, SCREEN_WIDTH/10);
    [_registerButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    [_registerButton setTitle:@"新用户注册" forState:UIControlStateNormal];
    _registerButton.titleLabel.font = [UIFont systemFontOfSize:15];
    
    _seekPassButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _seekPassButton.frame = CGRectMake(SCREEN_WIDTH/4.2 +100, SCREEN_HEIGHT/2.2, SCREEN_WIDTH/4, SCREEN_WIDTH/10);
    [_seekPassButton setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    _seekPassButton.tintColor = [UIColor redColor];
    [_seekPassButton setTitle:@"忘记密码?" forState:UIControlStateNormal];
    _seekPassButton.titleLabel.font = [UIFont systemFontOfSize:15];
    
    UILabel *quickLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2 - 30, SCREEN_HEIGHT -SCREEN_WIDTH/10 - SCREEN_WIDTH/6 - 30, SCREEN_WIDTH/6, 20)];
    quickLabel.text = @"快速登录";
    quickLabel.backgroundColor = [UIColor whiteColor];
    quickLabel.font = [UIFont systemFontOfSize:13];
    quickLabel.textColor = [UIColor grayColor];
    
    UIView *lineView = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/8, SCREEN_HEIGHT -SCREEN_WIDTH/10 - SCREEN_WIDTH/6 - 20, SCREEN_WIDTH/1.33, 1)];
    lineView.backgroundColor = [UIColor lightGrayColor];
    
    _qqLoginButton = [UIButton buttonWithType:UIButtonTypeCustom];
    _qqLoginButton.frame = CGRectMake(SCREEN_WIDTH/2 -80,SCREEN_HEIGHT - SCREEN_WIDTH/10 - SCREEN_WIDTH/6,SCREEN_WIDTH/2.5, SCREEN_WIDTH/9);
    _qqLoginButton.backgroundColor = [UIColor colorWithRed:66/255.0 green:128/255.0 blue:197/255.0 alpha:1.0];
    _qqLoginButton.center = CGPointMake(SCREEN_WIDTH/2, SCREEN_HEIGHT-60);
    [_qqLoginButton.layer setCornerRadius:SCREEN_WIDTH/20];
    [_qqLoginButton setTitle:@"QQ登录" forState:UIControlStateNormal];
    _qqLoginButton.titleLabel.font = [UIFont systemFontOfSize:14];
    _qqLoginButton.contentVerticalAlignment = UIControlContentVerticalAlignmentFill;//文字填充满
    _qqLoginButton.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
    [_qqLoginButton setImage:[UIImage imageNamed:@"iconfont-qqhaoma.png"] forState:UIControlStateNormal];
    _qqLoginButton.imageEdgeInsets = UIEdgeInsetsMake(5,SCREEN_WIDTH/12,5,SCREEN_WIDTH/4);
    _qqLoginButton.titleEdgeInsets = UIEdgeInsetsMake(0,SCREEN_WIDTH/5,0,SCREEN_WIDTH/5);
    
    [self addSubview:_phoneNumberTF];
    [self addSubview:_passWordTF];
    [self addSubview:_longinButton];
//    [self addSubview:protocolLabel];
//    [self addSubview:_protocolButton];
    [self addSubview:LBView];
    [self addSubview:_registerButton];
    [self addSubview:_seekPassButton];
   // [self addSubview:_qqLoginButton];
    //[self addSubview:lineView];
   // [self addSubview:quickLabel];
}


- (BOOL)textFieldShouldReturn:(UITextField*)textField
{
    if(textField == _phoneNumberTF) {
        [_phoneNumberTF becomeFirstResponder];
    }else{
        [_passWordTF resignFirstResponder];
    }
    return YES;
}

@end
